//
//  ViewController.m
//  HYRefresh
//
//  Created by HYMac on 16/3/4.
//  Copyright © 2016年 HYMac. All rights reserved.
//

#import "ViewController.h"
#import "UIScrollView+HYRefresh.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tabView;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
  
   [self.tabView addHeadRefreshWithTarget:self action:@selector(refresh)];
    [self.tabView addFootRefreshWithTarget:self action:@selector(refresh)];
}
- (void)refresh
{
    dispatch_async(dispatch_queue_create("", DISPATCH_QUEUE_CONCURRENT), ^{
        for (int i=0; i<10000; i++)
        {
            NSLog(@"1");
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.tabView endFootRefresh];
             [self.tabView endHeadRefresh];
        });
    });
    
   
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
    
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=[[UITableViewCell alloc]init];
    cell.textLabel.text=@"HY";
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tabView endFootRefresh];
    [self.tabView endHeadRefresh];
}

@end
